package com.zhou.gof.group.adapter;

import com.zhou.gof.group.adapter.adapter.OracleAdapterMysql;
import com.zhou.gof.group.adapter.mysql.Mysql;
import com.zhou.gof.group.adapter.mysql.impl.MysqlImpl;
import com.zhou.gof.group.adapter.oracle.Oracle;
import com.zhou.gof.group.adapter.oracle.impl.OracleImpl;
import com.zhou.gof.group.adapter.service.DBService;
import com.zhou.gof.group.adapter.service.impl.DBServiceImpl;

/**
 * @author zhoudong
 * @title: AdapterTest
 * @projectName user-app
 * @description: 适配器模式
 * @date 2019/5/29 18:15
 */
public class AdapterTest {

    public static void main(String[] args) {
        Oracle oracle = new OracleImpl();
        DBService dbService = new DBServiceImpl();
        System.out.println(dbService.readOracle(oracle));

        // 适配器开始
        Mysql mysql = new MysqlImpl();
        Oracle oracleAdapter = new OracleAdapterMysql(mysql);
        System.out.println(dbService.readOracle(oracleAdapter));

        /*
             输出结果
             reader from oracle db
             Adapter reader
             reader from mysql db
         */
    }
}
